package com.denlaku.longan.repository;

import com.denlaku.longan.anno.VarOp;
import com.denlaku.longan.dao.DashboardDao;
import com.denlaku.longan.qo.DashboardQuery;
import com.denlaku.longan.qo.Query;
import com.denlaku.longan.vo.Dashboard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author tianx
 */
@Repository
public class DashboardRepository {
    @Autowired
    private DashboardDao dashboardDao;

    /**
     * 新增仪表板
     * @param dashboard 仪表板
     */
    @VarOp
    public void add(Dashboard dashboard) {
        dashboardDao.add(dashboard);
    }

    /**
     * 更新仪表板
     * @param dashboard 仪表板
     */
    @VarOp
    public void update(Dashboard dashboard) {
        dashboardDao.update(dashboard);
    }

    /**
     * 删除仪表板
     * @param query 查询参数
     */
    public void delete(Query query) {
        dashboardDao.delete(query);
    }

    /**
     * 获取仪表板
     * @param query 查询参数
     * @return 仪表板
     */
    public Dashboard get(Query query) {
        return dashboardDao.get(query);
    }

    /**
     * 查询仪表板
     * @param dashboard 查询参数
     * @return 仪表板
     */
    public List<Dashboard> list(DashboardQuery dashboard) {
        return dashboardDao.list(dashboard);
    }

    /**
     * 清理tag
     *
     * @param tenantId 租户ID
     * @param tagId 标签ID
     */
    public void clearTag(Long tenantId, Long tagId) {
        dashboardDao.clearTag(tenantId, tagId);
    }
}
